package user;

import opreation.*;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:此类针对于管理员操作权限
 * Author:  LiuTao
 * Version: 1.0
 * Date:    2024-01-03  09:24
 */
public class AdminUser extends User{
    private String adminName;
    private String adminPassword;

    public AdminUser(String adminName, String adminPassword) {
        this.adminName = adminName;
        this.adminPassword = adminPassword;

        if (!adminLogin()) {
            System.out.println("管理员登录失败！");
            System.exit(0); // 如果登录失败，直接退出程序
        }
        System.out.println("恭喜您登陆成功!");

        this.iOpreation = new IOpreation[]{
                new ExitOpreation(),
                new FindOpreation(),
                new AddOpreation(),
                new DelOpreation(),
                new ShowOpreation()
        };
    }

    private boolean adminLogin() {
        Scanner scanner = new Scanner(System.in);

        System.out.println("请输入管理员帐号：");
        String inputAdminName = scanner.next();

        System.out.println("请输入管理员密码：");
        String inputAdminPassword = scanner.next();

        return adminName.equals(inputAdminName) && adminPassword.equals(inputAdminPassword);
    }

    public int menu() {

        System.out.println("********************************");
        System.out.println("******   欢迎进入管理员系统  ******");
        System.out.println("********   1.查找图书   *********");
        System.out.println("********   2.新增图书   *********");
        System.out.println("********   3.删除图书   *********");
        System.out.println("********   4.显示图书   *********");
        System.out.println("********   0.退出系统   *********");
        System.out.println("********************************");

        Scanner scanner = new Scanner(System.in);
        System.out.println("选择您要操作的选项：");
        int choice = scanner.nextInt();
        return choice;
    }


}
